<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" id="viewport" content="width=device-width, initial-scale=1">
  <title>登录页面</title>
  <!--    <link rel="stylesheet" href="https://unpkg.com/mint-ui/lib/style.css">-->
  <!--    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script>-->
  <!--    <script src="https://unpkg.com/mint-ui/lib/index.js"></script>-->
  <!--    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>-->
  <!--    <script src="https://cdn.bootcss.com/qs/6.5.1/qs.min.js"></script>-->
  <link rel="stylesheet" th:href="@{/formlist/common/style.css}">
  <script th:src="@{/formlist/common/vue.js}"></script>
  <script th:src="@{/formlist/common/index.js}"></script>
  <script th:src="@{/formlist/common/axios.min.js}"></script>
  <script th:src="@{/formlist/common/qs.min.js}"></script>
  <link th:href="@{/formlist/css/reset.css}" rel="stylesheet">
  <link th:href="@{/formlist/css/main.css}" rel="stylesheet">
</head>
<body>
<div id="applogin" class="login">
  <div class="title">疫情人员外出</br>大数据统计系统</div>
  <div class="username"><mt-field placeholder="请输入身份证号码" v-model="username"></mt-field></div>
  <div class="username"><mt-field  type="password" placeholder="请输入密码" v-model="password"></mt-field></div>
  <div class="btn"><mt-button @click.native="handleClick">确认登录</mt-button></div>
  <div class="clearfix">
    <div class="fl clearfix">
      <div class="fl rember"><mt-switch v-model="rememberPsw"></mt-switch></div>
      <div class="fl regist">记住密码</div>
    </div>
    <div class="fr">
      <div class="regist" v-on:click="registered">注册账号</div>
    </div>
  </div>
</div>
<script>

  const qs = Qs;
  const vm = new Vue({
    el: '#applogin',
    data: {
      message: 'hello',
      username: '',
      password: '',
      rememberPsw: false,
      sfz: '',
      mim: '',
      ifr: Boolean
    },
    created: function () {
      if (this.username) {
        this.remberPassword = true
      }
    },
    mounted() {
      console.log(localStorage.getItem('sfz'))
      console.log(localStorage.getItem('mim'))
      console.log(localStorage.getItem('ifr'))
      if (localStorage.getItem('ifr')) {
        this.username = localStorage.getItem('sfz')
        this.password = localStorage.getItem('mim')
        this.rememberPsw = true
      }
    },
    methods: {
      handleClick:function (event) {
        if (this.username === '') {
          this.$toast('请填写身份证号码！')
        } else if (this.password === '') {
          this.$toast('请填写密码！')
        } else {
          axios.post('/system/renyuan/login', qs.stringify({'zhanghao':this.username, 'mima': this.password})).then(res => {
            window.localStorage.setItem(
                    "userfindid",
                    this.username
            );
            if (res.data.code === 0) {
              if (this.rememberPsw) {
                window.localStorage.setItem(
                        "sfz",
                        this.username
                );
                window.localStorage.setItem(
                        "mim",
                        this.password
                );
                window.localStorage.setItem(
                        "ifr",
                        this.rememberPsw
                );
              } else {
                localStorage.removeItem("sfz");
                localStorage.removeItem("mim");
                localStorage.removeItem("ifr");
              }
              location.href = '../formlist/select';
            } else if (res.data.code === 500) {
              this.$toast(res.data.msg);
            }
          });
        }
      },
      registered:function (event) {
        location.href = '/system/formlist/register';
      }
    }

  })
</script>
</body>
</html>